{{extend 'layout.html'}}

<script type="text/javascript">
     $(document).ready(function(){
    	 $("#dialog-confirm").dialog({ autoOpen: false });         
	 });

	function delete_project(prj_id) {	  
	 	  $("#dialog-confirm").dialog("open");
	 	  $("#dialog-confirm").dialog({
	 		  autoOpen: false,
	 		  modal:true,
	 		  buttons : {
	 			"Yes" : function() {              
	 				$(this).dialog("close");
	 				// get call:
	 				window.location.href='delete_project/' + prj_id;
	 				return   				   	   			    			   				       			
	 			},
	 			"No" : function() {
	 				$(this).dialog("close");
				}
			}
		});	  	  
	 }
</script>
<br/>
<br/>
<div id="dialog-confirm" title="Confirm">
	{{=T('Are you sure you want to delete the project with all its items?')}} 
</div>
<table style="border-collapse: separate; border-spacing: 5px">
	<thead>
		<tr>
			<th style="width: 80px">
				{{=T('Code')}}
			</th>
			<th style="width: 150px">
				{{=T('Description')}}
			</th>
			<th style="width: 150px">
				{{=T('Source Language')}}
			</th>
			<th></th>
			<th></th>
		</tr>
	</thead>	
	{{for i, prj in enumerate(projects):}}
		{{=TR(
				TD( 
					A(prj.project.code, _href=URL('project/%s' %prj.project.id ))), 
				TD(prj.project.description),
				TD(prj.language.description),
				TD(
					A(
					IMG(_src=URL( request.application , 'static/images', 'application_edit.png')), _href=URL('project/%s' %prj.project.id))),
				TD(A(
					IMG(_src=URL( request.application , 'static/images', 'cancel.png')), _href='#' , _onclick='delete_project(\'%s\')' %prj.project.id)),				
					_class='even' if not i%2 else 'odd' )}}

	{{pass}}
</table>
<br/>
<form method="post" enctype="multipart/form-data" action="">
<table>
	<tbody>
		<tr id="project_code__row">
			<td class="w2p_fl"><label id="project_code__label" for="project_code">Code: </label></td>
			<td class="w2p_fw"><input name="code" id="project_code" class="string"></td>
			<td class="w2p_fc"></td>
		</tr>
		<tr id="project_description__row">
			<td class="w2p_fl"><label id="project_description__label" for="project_description">Description: </label></td>
			<td class="w2p_fw"><input name="description" id="project_description" class="string"></td>
			<td class="w2p_fc"></td>
		</tr>
		<tr id="project_source_language__row">
			<td class="w2p_fl"><label id="project_source_language__label" for="project_source_language">Source Language: </label></td>
			<td class="w2p_fw">				
				<select name="source_language" id='project_language_language'>
        			{{for l in languages:}}
            			{{=OPTION(l.description, _value=l.id)}}
        			{{pass}}
     			</select>			
			</td>
			<td class="w2p_fc"></td>
		</tr>
		<tr id="submit_record__row">
			<td class="w2p_fl"></td>
			<td class="w2p_fw"><input type="submit" value="Submit"></td>
			<td class="w2p_fc"></td>
		</tr>
	</tbody>
</table>
	<div class="hidden" style="display: none;">
		<input type="hidden" value="project_create" name="_formname">
	</div>
</form>